<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="./templates/default.xhtml">
            <ui:define name="content">
                <h:form binding="#{contactManagerBean.loadContactList}">
                    <p:panel header="Contact List" id="contactPanel">
                        <p:dataTable id="contacts" var="contacts" value="#{contactManagerBean.contacts}" paginator="false" 
                                     selectionMode="single" rowSelectListener="#{contactManagerBean.onRowSelect}"
                                     emptyMessage="No contacts found with given criteria."
                                     selection="#{contactManagerBean.selectedContact}">
                            <!--<p:column selectionMode="multiple" />-->
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Select" />
                                </f:facet>
                                <h:selectBooleanCheckbox value="#{contactManagerBean.selectedIds[contacts.userId]}" />
                            </p:column>
                            <p:column filterBy="#{contacts.userId}" headerText="User Id" filterMatchMode="contains">  
                                <h:outputText value="#{contacts.userId}" />  
                            </p:column> 
                            <p:column filterBy="#{contacts.name}" headerText="Name" filterMatchMode="contains">  
                                <h:outputText value="#{contacts.name}" />  
                            </p:column>
                            <p:column filterBy="#{contacts.designation}"   
                                      headerText="Designation"
                                      filterOptions="#{contactManagerBean.designationOptions}"  
                                      filterMatchMode="exact">  
                                <h:outputText value="#{contacts.designation}" />  
                            </p:column>  
                            <p:column filterBy="#{contacts.department}"   
                                      headerText="Department"
                                      filterOptions="#{contactManagerBean.departmentOptions}"  
                                      filterMatchMode="contains">  
                                <h:outputText value="#{contacts.department}" />  
                            </p:column>  
                            <f:facet name="footer">  
                                <p:commandButton value="Send Message" actionListener="#{contactManagerBean.sendMessage}" ajax="true"/>
                            </f:facet> 
                        </p:dataTable>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>